zynqmp: pm: Implement PLL get mode EEMI API
authorJolly Shah <[email protected]>
Fri, 4 Jan 2019 19:35:48 +0000 (11:35 -0800)
committerJolly Shah <[email protected]>
Fri, 4 Jan 2019 19:36:00 +0000 (11:36 -0800)
This API will be used to get the currently configured PLL mode:
reset (bypassed and unlocked), integer or fractional (locked).

Signed-off-by: Mirela Simonovic <[email protected]>
Acked-by: Will Wong <[email protected]>
Signed-off-by: Jolly Shah <[email protected]>
plat/xilinx/zynqmp/pm_service/pm_api_sys.c
plat/xilinx/zynqmp/pm_service/pm_api_sys.h
plat/xilinx/zynqmp/pm_service/pm_defs.h
plat/xilinx/zynqmp/pm_service/pm_svc_main.c

index b37512a23f4ba679525033f3f36ec9304cf5a97d..171c7e6c9d6eb2fc38312b4c048bce2c95f683c3 100644 (file)
@@ -1326,3 +1326,24 @@ enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode)
        PM_PACK_PAYLOAD3(payload, PM_PLL_SET_MODE, nid, mode);
        return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
 }
+
+/**
+ * pm_pll_get_mode() - Get the PLL mode
+ * @nid                Node id of the target PLL
+ * @mode       Location to store the mode of the PLL
+ *
+ * @return     Error if an argument is not valid or status as returned by the
+ *             PM controller (PMU)
+ */
+enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode)
+{
+       uint32_t payload[PAYLOAD_ARG_CNT];
+
+       /* Check if given node ID is a PLL node */
+       if (nid < NODE_APLL || nid > NODE_IOPLL)
+               return PM_RET_ERROR_ARGS;
+
+       /* Send request to the PMU */
+       PM_PACK_PAYLOAD2(payload, PM_PLL_GET_MODE, nid);
+       return pm_ipi_send_sync(primary_proc, payload, mode, 1);
+}
index 9b211f5f74ecc4c7e20435e25944df37c8f709a8..bc96c1f9fab251fd5af291d3ce38020f43aea735 100644 (file)
@@ -185,5 +185,6 @@ enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
                                unsigned int *value);
 
 enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode);
+enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode);
 
 #endif /* PM_API_SYS_H */
index 5927cafbb36961b78e08df0e5b2d79e34308e349..7c2389385aba06d071323fefbe725af4bcc64d6b 100644 (file)
@@ -96,6 +96,7 @@ enum pm_api_id {
        PM_PLL_SET_PARAMETER,
        PM_PLL_GET_PARAMETER,
        PM_PLL_SET_MODE,
+       PM_PLL_GET_MODE,
        PM_API_MAX
 };
 
index 881a593360057175013dc995ab7fdd95a8790188..a18f84506e440677646ed4a71612a19c339c5fa5 100644 (file)
@@ -579,6 +579,14 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
                ret = pm_pll_set_mode(pm_arg[0], pm_arg[1]);
                SMC_RET1(handle, (uint64_t)ret);
 
+       case PM_PLL_GET_MODE:
+       {
+               uint32_t mode;
+
+               ret = pm_pll_get_mode(pm_arg[0], &mode);
+               SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32));
+       }
+
        default:
                WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
                SMC_RET1(handle, SMC_UNK);